<template>
	<view class="shopper-item">
		<view class="chackitem" v-if="ischeck">
			<checkbox-group @change="checkok">
				<label>
					<checkbox :value="data.id" :checked="xiadata.includes(data.id)"/><text></text>
				</label>
			</checkbox-group>
		</view>
		<view class="l">
			<view class="logo">新品</view>
			<image :src="'http://127.0.0.1:3006'+data.img" mode="aspectFill"></image>
			<view class="l-b" v-if="data.status!=1">{{isstatus}}</view>
		</view>
		<view class="r">
			<view class="r-tit">{{data.title}}</view>
			<view class="mai" v-if="!ischeck">月售10</view>
			<!-- <view class="sum">库存10 <view class="iconfont icon-bianji"></view> -->
			<!-- </view> -->
			<view class="dd" v-if="!ischeck">单点不送</view>
			<view class="price">￥{{data.price}}</view>
		</view>
	</view>
</template>

<script setup>
import { computed } from 'vue';
const emit=defineEmits(['xia'])
	const prop = defineProps({
		ischeck: {
			type: Boolean,
			default: false
		},
		data:{
			type:Object
		},
		xiadata:{
			type:Object
		}
	})
	const isstatus=computed(()=>{
		   switch(prop.data.status){
			   case 0:return "正在审核"
			   case 2:return "审核失败"
			   case 3:return "已下架"
		   }
	})
	const checkok=e=>{
		 if(e.detail.value.length){
			 emit('xia',{id:prop.data.id,select:true})
			 return
		 }
		 emit('xia',{id:prop.data.id,select:false})
	}
</script>

<style scoped lang="scss">
	.shopper-item {
		width: 100%;
		height: 200rpx;
		display: flex;
		overflow: hidden;
		margin-bottom: 40rpx;
		gap: 10rpx;

		.chackitem {
			width: 70rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			checkbox{
				transform: scale(0.8);
			}
		}

		.l {
			height: 100%;
			width: 200rpx;
			position: relative;
			border-radius: 10rpx;
			overflow: hidden;

			.logo {
				position: absolute;
				padding: 20rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				background-color: orange;
			}

			image {
				position: absolute;
				height: 200rpx;
				width: 200rpx;

			}

			.l-b {
				position: absolute;
				bottom: 0;
				width: 100%;
				height: 40rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				font-size: 23rpx;
				background-color: rgba(0, 0, 0, 0.3);
				backdrop-filter: blur(10rpx);
				color: #fff;
			}
		}

		.r {
			flex: 1;
			overflow: hidden;
			display: flex;
			flex-direction: column;
			font-size: 25rpx;

			.price {
				color: red;
				font-weight: 700;
			}

			>view {
				flex: 1;
				color: #7b7b7b;
			}

			.sum {
				display: flex;
			}

			.r-tit {
				font-weight: 700;
				color: #000;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}

		}
	}
</style>